﻿using MadMediaManager.Core.Domain;

namespace MadMediaManager.DataAccess.Mappings
{
    public class IsoMapping : BaseMapping<Iso, string>
    {
        public IsoMapping()
        {
            Component(i => i.FileSize, uv =>
                                           {
                                               uv.Map(i => i.Unit)
                                                   .Column("UnitType")
                                                   .Not.Nullable();

                                               uv.Map(i => i.Value)
                                                   .Column("UnitValue")
                                                   .Nullable();
                                           });

            Map(i => i.Name)
                .Length(100)
                .Not.Nullable();
            
            Map(i => i.Image)
                .Nullable();

            Map(i => i.Year)
                .Nullable();

            DiscriminateSubClassesOnColumn("Type");

            Map(i => i.IsoType)
                .CustomType(typeof(IsoType))
                .Not.Nullable();

            Map(i => i.Rating)
                .CustomType(typeof(Rating))
                .Not.Nullable();

            Map(i => i.IsFileFound)
                .Not.Nullable();
        }
    }
}
